import type { App } from 'vue'
import { defineAsyncComponent } from 'vue'
import LoadingComp from '../components/Loading/index.vue'

const compModules = import.meta.glob('workspace/layout/Panel/comps/**/*.vue')
const styleModules = import.meta.glob('workspace/layout/Config/comps/com/custom/styles/**/*.vue')

export default function (app: App) {
  for(let key in compModules) {
    app.component(key.split('/').at(-2) as string, defineAsyncComponent<any>({
      loader: compModules[key],
      loadingComponent: LoadingComp,
      delay: 0
    }))
  }
  for(let key in styleModules) {
    app.component(key.split('/').at(-2) + 'Config', defineAsyncComponent<any>({
      loader: styleModules[key],
      loadingComponent: LoadingComp,
      delay: 0
    }))
  }
}